package chxy.sys.controller;


import chxy.sys.model.PointRecord;
import chxy.sys.service.PointRecordService;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author SR.Y
 * @since 2021-03-13
 */
@RestController
@RequestMapping("/sys/pointRecord")
public class PointRecordController {
    @Autowired
    private PointRecordService pointrecordService;



    /**
     * pointrecord生成
     */
    @RequestMapping(value = "/createPointRecord", method = RequestMethod.POST)
    @ResponseBody
    public void createPointRecord(@RequestBody PointRecord b) {

        pointrecordService.save(b);
    }

    /**
     * pointrecord修改
     */
    @RequestMapping(value = "/updatePointRecord/{id}", method = RequestMethod.POST)
    @ResponseBody
    public boolean updatePointRecord(@PathVariable String id, @RequestBody PointRecord b) {
        b.setId(id);
        return pointrecordService.update(b);
    }

    /**
     * pointrecord删除
     */
    @RequestMapping(value = "/deletePointRecord/{id}", method = RequestMethod.POST)
    @ResponseBody
    public boolean deletePointRecord(@PathVariable String id, @RequestBody PointRecord b) {
        b.setId(id);
        return pointrecordService.delete(b);
    }


    /**
     * pointrecord查询
     */
    @RequestMapping(value = "/list", method = RequestMethod.GET)
    @ResponseBody
    public Page<PointRecord> list(@RequestParam(value = "pageSize", defaultValue = "5") Integer pageSize,
                            @RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum) {
        System.out.println("进入了pointrecord查询");

        return pointrecordService.list(pageSize, pageNum);
    }

}

